BR2_GLOBAL_PATCH_DIR="../global_patch_dir"
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="../kernel_config_fragment"
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="../busybox_config_fragment"
BR2_PACKAGE_KERNEL_MODULE=y
BR2_PACKAGE_OVERRIDE_FILE=../buildroot_override
BR2_PACKAGE_STRACE=y
BR2_ROOTFS_OVERLAY="../rootfs_overlay"

## Host GDB
BR2_GDB_VERSION="7.11.1"
BR2_GDB_VERSION_7_10=n
BR2_GDB_VERSION_7_11=y
BR2_GDB_VERSION_7_12=n
BR2_PACKAGE_HOST_GDB=y
BR2_PACKAGE_HOST_GDB_PYTHON=y
BR2_PACKAGE_HOST_GDB_SIM=y
BR2_PACKAGE_HOST_GDB_TUI=y

## QEMU.
BR2_PACKAGE_HOST_QEMU=y
# False because otherwise we need the host to be as recent as guest.
BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE=n
BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y
BR2_PACKAGE_HOST_QEMU_VDE2=y

## Target GDB
# This is preparation for target GDB / gdbserver.
# But those options require a toolchain with threads like glibc,
# which I'm afraid will make compilation slower, so let's leave it
# at that for now since our focus is kernel debug.
#BR2_DEBUG_1=n
#BR2_DEBUG_2=n
#BR2_DEBUG_3=y
#BR2_ENABLE_DEBUG=y
#BR2_OPTIMIZE_0=y

# ftrace
BR2_PACKAGE_TRACE_CMD=y

# GPIO: lsgpio, gpio-event-mon, gpio-hammer
BR2_PACKAGE_LINUX_TOOLS=y
BR2_PACKAGE_LINUX_TOOLS_GPIO=y

# DTC
BR2_PACKAGE_DTC=y
BR2_PACKAGE_DTC_PROGRAMS=y
BR2_PACKAGE_HOST_DTC=y

# On ARM, with our lkmc_platform_device:
#
#     devmem2 0x101e9000 w 0x12345678
#
# Then on QEMU monitor, notice that the registers don't actually change value:
#
#     xp/4 0x101e9000
#
# Uses /dev/mem.
#
# Upstream: http://free-electrons.com/pub/mirror/devmem2.c
#
# See also:
#
# - https://superuser.com/questions/71389/what-is-dev-mem/1214662#1214662
# - https://unix.stackexchange.com/questions/4948/shell-command-to-read-device-registers
# - man mem
#
# TODO: why with mmap MAP_PRIVATE (used in my previous custom naive version),
# the entire register page is read?;
#
# TODO: have a look at: https://github.com/kaiwan/device-memory-readwrite
#
BR2_PACKAGE_DEVMEM2=y
